package demo6;

import java.util.Objects;

class Person{
    private String name ; 
    private int age ; 
    public Person(String name, int age) {

        this.age = age ; 
        this.name = name ;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return age == person.age && Objects.equals(name, person.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }
}
 public class Test {
    public static void main(String[] args) {
        Person p1 = new Person("gaobo", 20) ; 
        Person p2 = new Person("gaobo", 20) ; 
        int a = 10;
        int b = 10;
        System.out.println(a == b);             // 输出true
        System.out.println(p1 == p2);           // 输出false
        System.out.println(p1.equals(p2));      // 输出false
    }
 }